import C from './Crypto';
(function () {
  // Shortcut
  var util = C.Crypto.util;

  // Convert n to unsigned 32-bit integer
  util.u32 = function (n) {
    return n >>> 0;
  };

  // Unsigned 32-bit addition
  util.add = function () {
    var result = this.u32(arguments[0]);
    for (var i = 1; i < arguments.length; i++)
      result = this.u32(result + this.u32(arguments[i]));
    return result;
  };

  // Unsigned 32-bit multiplication
  util.mult = function (m, n) {
    return this.add((n & 0xffff0000) * m, (n & 0x0000ffff) * m);
  };

  // Unsigned 32-bit greater than (>) comparison
  util.gt = function (m, n) {
    return this.u32(m) > this.u32(n);
  };

  // Unsigned 32-bit less than (<) comparison
  util.lt = function (m, n) {
    return this.u32(m) < this.u32(n);
  };
})();
